package cn.kgc.mcartoon.configration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
 * Redis配置类，修改序列化默认配置
 */

@Configuration
@Component
public class RedisConfigration {

    @Bean
    public RedisTemplate<Object, Object> jsonRedisTemplate(RedisConnectionFactory redisConnectionFactory){
        RedisTemplate<Object, Object> template = new RedisTemplate();
        template.setDefaultSerializer(new Jackson2JsonRedisSerializer(Object.class) );
        template.setConnectionFactory(redisConnectionFactory);
        return template;
    }
}
